﻿using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls;

namespace Wpf_Examples.ViewModels
{
    public class ViewModelLocator
    {
        public IServiceProvider Services { get; }
        public ViewModelLocator()
        {
            Services = ConfigureServices();
        }
        private static IServiceProvider ConfigureServices()
        {
            var services = new ServiceCollection();

            //这里实现所有viewModel的容器注入
            services.AddSingleton<MainViewModel>();
            services.AddTransient<LEDStatusViewModel>();
            services.AddTransient<ImageButtonViewModel>();
            services.AddTransient<DataCardViewModel>();
            services.AddTransient<GroubBoxViewModel>();
            services.AddTransient<RadarViewModel>();
            services.AddTransient<PageBarViewModel>();
            services.AddTransient<ButtonViewModel>();
            services.AddTransient<MultiYChartViewModel>();
            services.AddTransient<ComboxViewModel>();
            services.AddTransient<LogPanelViewModel>();
            services.AddTransient<LanguageChangeViewModel>();
            services.AddTransient<ListBoxMenuViewModel>();
            
            //添加其他 viewModel

            return services.BuildServiceProvider();
        }

        public MainViewModel Main => Services.GetService<MainViewModel>();
        public LEDStatusViewModel LedStatus => Services.GetService<LEDStatusViewModel>();
        public ImageButtonViewModel ImageButton => Services.GetService<ImageButtonViewModel>();
        public DataCardViewModel DataCard => Services.GetService<DataCardViewModel>();
        public GroubBoxViewModel GroupBox => Services.GetService<GroubBoxViewModel>();
        public RadarViewModel Radar => Services.GetService<RadarViewModel>();
        public PageBarViewModel PageBar => Services.GetService<PageBarViewModel>();
        public ButtonViewModel FButton => Services.GetService<ButtonViewModel>();
        public MultiYChartViewModel MultiY => Services.GetService<MultiYChartViewModel>();
        public ComboxViewModel CBox=> Services.GetService<ComboxViewModel>();
        public LogPanelViewModel LogPanel => Services.GetService<LogPanelViewModel>(); 
        public LanguageChangeViewModel LanguageChange => Services.GetService<LanguageChangeViewModel>(); 
        public ListBoxMenuViewModel ListBoxMenu => Services.GetService<ListBoxMenuViewModel>();

    }
}
